package com.example.store2.Mapper;

import com.example.store2.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    /**
     * 显示用户信息
     * @param username
     * @return
     */
    @Select("select * from user_table,occupation where user_table.occupation_id=occupation.id and username=#{username}")
    User show(String username);

    /**
     * 修改用户信息
     * @param user
     */
    @Update("update user_table set name=#{name},introduce=#{introduce},update_time=#{updateTime},jurisdiction=#{jurisdiction},occupation_id=#{occupationId} where id=#{id}")
    void update(User user);

    @Select("select * from user_table where username=#{username} and password=#{password}")
    User login(User user);

    @Select("select * from user_table where username=#{username}")
    User find(User user);

    @Insert("insert into user_table(username,password)values(#{username},#{password})")
    void add(User user);

    @Select("select jurisdiction from user_table where id=#{id}")
    Integer getbyid(Integer id);
}
